<!DOCTYPE html>
<html class="loginHtml">
<head>
    <title>${(dataDictMap['系统名称'].value)!}</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
<#--<link rel="stylesheet" href="/style/admin.css" media="all">-->
    <link rel="stylesheet" href="/style/public.css" media="all">
</head>
<body>
<div style="width: 100%;text-align: center;font-size: 50px;color: #ffffff;font-weight: bold;position: absolute;top:5%;right: 10%">
    <img src="/images/title.png">
</div>
<div style="margin-top: 10%">
    <div class="layui-col-xs8" style="margin-left: 5%">
        <img src="/images/build.jpg">
    </div>
    <div class="layui-col-xs3" style="width: 15%;margin-top: 5%">
        <div>
            <form class="layui-form" >
                <div class="login_face"><img src="/images/face.jpg" class="userAvatar"></div>
                <div class="layui-form-item input-item">
                    <label for="username">用户名</label>
                    <input type="text" placeholder="请输入用户名" autocomplete="off" id="username" name="username" value=""
                           class="layui-input" lay-verify="required">
                </div>
                <div class="layui-form-item input-item">
                    <label for="password">密码</label>
                    <input type="password" placeholder="请输入密码" autocomplete="off" id="password" name="password" value=""
                           class="layui-input" lay-verify="required">
                </div>
            <#if (dataDictMap['验证码']?? && dataDictMap['验证码'].value == "1")>
                <div class="layui-form-item input-item" id="imgCode">
                    <label for="code">验证码</label>
                    <input type="text" placeholder="请输入验证码" autocomplete="off" id="randomcode" name="randomcode"
                           class="layui-input"
                           lay-verify="required">
                    <img src="/validateCodeServlet" class="layadmin-user-login-codeimg" id="vercode_img"
                         style="height: 100%;">
                </div>
            </#if>
                <div class="layui-form-item">
                    <button type="button" id="submitBtn" class="layui-btn layui-btn-fluid" lay-submit
                            lay-filter="LAY-user-login-submit">登 入
                    </button>
                </div>
                <div class="layui-form-item layui-row" style="text-align: center">
                   技术支持：北京佳木东方有限公司
                </div>
            </form>
        </div>
        <div style="margin-top: 50%;margin-left: -15%">
            <img src="/images/zhongjian.jpg">
        </div>
    </div>
</div>

<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/lib/login.js" charset="utf-8"></script>
<script src="/plugins/jquery/jquery.min.js" charset="utf-8"></script>
<script src="/plugins/jquery/jquery.base64.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();
        form.on("submit(LAY-user-login-submit)", function (obj) {
            var username = $.base64.encode($("#username").val());
            var password = $.base64.encode($("#password").val());
            var randomcode = $.base64.encode($("#randomcode").val());
//            var vcode = $("#vcode").val();
            var rememberMe = $('#rememberMe').is(':checked');
            $.post("/login/validate", {
                "username": username,
                "password": password,
                "randomcode": randomcode,
//                "vcode" : vcode,
                "rememberMe": rememberMe
            }, function (data) {
                if (data.status == '0') {
                    window.localStorage.setItem("lock", "");
                    layer.msg('登录成功，进入系统', {
                        offset: '15px'
                        , icon: 1
                        , time: 500
                    }, function () {
                        top.location.href = '/';
                    });
                } else {
                    layer.msg(data.message, {offset: '15px', anim: 6, icon: 2, time: 2000});
                    reloadCode();
                }
            });
        });

        function reloadCode() {
            var vercode_img = $("#vercode_img").get(0);
            vercode_img.src = "/validateCodeServlet?t=" + new Date().getTime();
        }

        $("#vercode_img").click(function () {
            reloadCode();
        });
        $("body").keydown(function () {
            if (event.keyCode == "13") {//keyCode=13是回车键
                $('#submitBtn').click();
            }
        });
    });
</script>
</body>
</html>
